/**
*  \file absdiff.h
*
*  \brief Absolute difference
*
*  \author Linyi <yi.lin@linde-china.com>
*
*
*/
#ifndef ABSDIFF_H_INCLUDED
#define ABSDIFF_H_INCLUDED

/*================================================[ public includes  ]================================================*/
#include "../cfg/prj.h"

/*================================================[ public defines   ]================================================*/

#define ABSDIFF( x, y )   (x > y ? x-y : y-x )

/*================================================[ public datatypes ]================================================*/

/*================================================[ inline functions ]================================================*/


/**  Absolute difference of U8 numbers.
*
*  The function returns the absolute difference of two numbers x, y, which is given by |x-y|.
*
*  \param x
*  \param y
*
*  \return The absolute difference of the passed values.
*/
STATIC_INLINE U8 absdiff_u8( U8 x, U8 y)  { return ABSDIFF(x,y); }

/**  Absolute difference of S8 numbers.
*
*  The function returns the absolute difference of two numbers x, y, which is given by |x-y|.
*
*  \param x
*  \param y
*
*  \return The absolute difference of the passed values.
*/
STATIC_INLINE U8 absdiff_s8( S8 x, S8 y)  { return ABSDIFF(x,y); }

/**  Absolute difference of U16 numbers.
*
*  The function returns the absolute difference of two numbers x, y, which is given by |x-y|.
*
*  \param x
*  \param y
*
*  \return The absolute difference of the passed values.
*/
STATIC_INLINE U16 absdiff_u16( U16 x, U16 y)  { return ABSDIFF(x,y); }

/**  Absolute difference of S16 numbers.
*
*  The function returns the absolute difference of two numbers x, y, which is given by |x-y|.
*
*  \param x
*  \param y
*
*  \return The absolute difference of the passed values.
*/
STATIC_INLINE U16 absdiff_s16( S16 x, S16 y)  { return ABSDIFF(x,y); }

/**  Absolute difference of U32 numbers.
*
*  The function returns the absolute difference of two numbers x, y, which is given by |x-y|.
*
*  \param x
*  \param y
*
*  \return The absolute difference of the passed values.
*/
STATIC_INLINE U32 absdiff_u32( U32 x, U32 y)  { return ABSDIFF(x,y); }

/**  Absolute difference of S32 numbers.
*
*  The function returns the absolute difference of two numbers x, y, which is given by |x-y|.
*
*  \param x
*  \param y
*
*  \return The absolute difference of the passed values.
*/
STATIC_INLINE U32 absdiff_s32( S32 x, S32 y)  { return ABSDIFF(x,y); }

/*====================================================================================================================*/

#endif

/***********************************************************************************************************************
*                             Copyright 2018 Linde Material Handling. All rights reserved.                             *
***********************************************************************************************************************/
